#!/bin/sh

if ! which gnuplot > /dev/null 2>&1
then
    echo "gnuplot not found - skipping graph creation" >&2
    exit 1
fi

graphFile=$(foamListTimes -latestTime)/patch.xy

gnuplot<<EOF

    set terminal postscript eps size 8,9 color enhanced font "Helvetica,20"
    set output "./validation/$(basename "$PWD")Properties.eps"
    set multiplot layout 2,2
    set decimalsign '.'
    set grid

    set key at graph 0.65,0.95
    set ylabel 'Vertical coordinate (m)'
    set yrange [0:4]

    set xtics rotate by -45

    set xlabel 'Departure diameter (mm)'
    plot \
        "postProcessing/patchWallBoilingProperties/$graphFile" \
        u (\$4*1e3):1 w l lt 1 t 'Simulation' \

    set xlabel 'Departure frequency (Hz)'
    plot \
        "postProcessing/patchWallBoilingProperties/$graphFile" \
        u 5:1 w l lt 1 t 'Simulation' \

    set xlabel 'Nucleation Site Density (1/mm^2)'
    plot \
        "postProcessing/patchWallBoilingProperties/$graphFile" \
        u (\$6/1e6):1 w l lt 1 t 'Simulation' \

    set xlabel 'Heat flux partitioning function, liquid (-)'
    plot \
        "postProcessing/patchWallBoilingProperties/$graphFile" \
        u 7:1 w l lt 1 t 'Simulation' \

    set key at graph 0.99,0.95

    unset multiplot

EOF

#------------------------------------------------------------------------------
